treeview: Make sure the editing widget's top left is always visible
authorColomban Wendling <ban@herbesfolles.org>
Wed, 10 Feb 2016 18:43:34 +0000 (19:43 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 12 Feb 2016 03:41:58 +0000 (22:41 -0500)
https://bugzilla.gnome.org/show_bug.cgi?id=761838

gtk/gtktreeview.c

index 7fca5f869676b3e942a7ba8b30a452fbea2d4806..c17cca67d468e71160e5b59253829bb11eb8bbd8 100644 (file)
@@ -2978,6 +2978,7 @@ gtk_tree_view_size_allocate (GtkWidget     *widget,
       GtkTreeViewChild *child = tmp_list->data;
       GtkTreePath *path;
       GdkRectangle child_rect;
+      int min_x, max_x, min_y, max_y;
       int size;
 
       path = _gtk_tree_path_new_from_rbtree (child->tree, child->node);
@@ -3003,6 +3004,14 @@ gtk_tree_view_size_allocate (GtkWidget     *widget,
           child_rect.height += size;
         }
 
+      /* push the rect back in the visible area if needed, preferring the top left corner */
+      min_x = gtk_adjustment_get_value (tree_view->priv->hadjustment);
+      max_x = min_x + allocation->width - child_rect.width;
+      min_y = 0;
+      max_y = min_y + allocation->height - gtk_tree_view_get_effective_header_height (tree_view) - child_rect.height;
+      child_rect.x = MAX (min_x, MIN (child_rect.x, max_x));
+      child_rect.y = MAX (min_y, MIN (child_rect.y, max_y));
+
       gtk_tree_path_free (path);
       gtk_widget_size_allocate (child->widget, &child_rect);
     }